package jude.java.money.batch.task;

import static jude.java.money.batch.Definition.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import jude.java.money.batch.Definition;
import jude.java.money.batch.Parameter;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;

/**
 * 批量增加或修改文件
 * */
public class BatchTest extends BatchTask<String[]> {
	
	public BatchTest(Parameter<String[]> p) {
		super(p);
	}
	
	@Override
	protected void initFlags() {
		super.initFlags();
		removeFlags(Definition.CONFIG_IGNORE);
	}
	
	private String getCode() {
		return "echo '"+SUCCESS+"';\r\ndie();";
	}
	
	@Override
	protected String getLabel() {
		return "TEST";
	}
	
	protected void execute(String site, String url, int group, int index) throws IOException {
		HttpClient client = getHttpClient();
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new NameValuePair("key", P.KEY));
		params.add(new NameValuePair("value", getCode()));
		PostMethod post = getPostMethod(url, params);
		shieldPost(0, site, client, post);
		
	}
}
